package com.oig.sys.suport;

import com.oig.sys.security.support.SecurityUser;
import com.oig.sys.security.util.SecurityUtil;
import org.springframework.data.domain.AuditorAware;

import java.util.Optional;

public class SecurityAuditorAware implements AuditorAware<Integer> {

    @Override
    public Optional<Integer> getCurrentAuditor() {
        SecurityUser user = SecurityUtil.getUser();
        if (user!=null){
            return Optional.of(user.getId());
        }
        return Optional.of(0);
    }


}
